package cn.gz.lbs.servlet;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.gz.lbs.main.SPRequestManager;
import cn.gz.zoomtech.common.ConfManager;
import cn.gz.zoomtech.common.db.DbHandle;


import test.Test;

/**
 * Servlet implementation class LbsProxyServer
 */
public class SpDemoReportServer extends HttpServlet {
	private static final long serialVersionUID = 1L;
	 private static final Log log = LogFactory.getLog(SpDemoReportServer.class);
	 private static CompositeConfiguration cf = ConfManager.getInstance().getConf();
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SpDemoReportServer() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			// step0: 客户端IP信息：
			String clientIp = request.getRemoteHost();
			log.info("LbscIp:" + clientIp);
			// step1: 读取客户端请求,输出请求字符串
			InputStreamReader reader = new InputStreamReader(
					request.getInputStream(), "utf-8");
			char[] buff = new char[1024];
			int length = 0;
			String reqStrs = "";
			while ((length = reader.read(buff)) != -1) {
				reqStrs = reqStrs + new String(buff, 0, length);
			}
			log.info("LbscReportLtrrStr:" + reqStrs);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	
	}

}
